import time

from selenium import webdriver
from selenium.webdriver.common.by import By


def element_intercation():
    driver=webdriver.Chrome()
    driver.get("http://www.baidu.com")
    #输入、点击、清除在 Selenium 中对应的方法分别是 send_keys、click、clear

    driver.find_element(By.ID,"kw").send_keys("霍格沃兹测试学院")
    time.sleep(3)
    driver.find_element(By.ID,"su").click()
    time.sleep(3)
    driver.find_element(By.ID,"kw").clear()

def get_attribute():
    driver = webdriver.Chrome()
    driver.get("http://www.baidu.com")
    a=driver.find_element(By.ID,"su")
    
    #获取元素标签上的属性 get_attribute('value')
    result=a.get_attribute("class")
    print(result)

if __name__ == '__main__':
    #element_intercation()
    get_attribute()